package com.warehouse.service.impl;

import com.warehouse.dto.Ware;
import com.warehouse.dto.WareInfo;
import com.warehouse.entity.Warehouse;
import com.warehouse.mapper.WarehouseMapper;
import com.warehouse.service.WarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

//仓库管理业务接口实现层
@Service
public class WarehouseServiceImpl implements WarehouseService {
    //注入
    @Autowired(required = false)
    private WarehouseMapper warehouseMapper;

    /**
     * 模糊查询仓库名称
     * @param name
     * @return
     */
    @Override
    public List<Warehouse> findLikeWareNmae(String name) {
        List<Warehouse> list=warehouseMapper.findLikeWareNmae("%"+name+"%");
        return list;
    }

    /**
     * 新增仓库
     * @param warehouse 仓库实体
     * @return
     */
    @Override
    public boolean insertWare(Warehouse warehouse) {
        boolean flag= warehouseMapper.insertWare(warehouse);
        if(flag){
            return true;
        }
        return false;
    }

    /**
     * 更新仓库
     * @param warehouse 更改的信息
     * @return
     */
    @Override
    public boolean updateWare(Warehouse warehouse) {
        boolean flag=warehouseMapper.updateWare(warehouse);

        if (flag){
            return true;
        }
        return false;
    }

    /**
     * 查看仓库信息
     * @return
     */
    @Override
    public List<Warehouse> findwareInfo() {
        List<Warehouse> list=warehouseMapper.findwareInfo();
        return list;
    }

    @Override
    public WareInfo wareInfo(String wareName) {
       WareInfo wareInfo= warehouseMapper. wareInfo(wareName);
        return wareInfo;
    }
}
